<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
<title>优惠券列表</title>
<link rel="stylesheet" href="__PUBLIC__/Admin/css/css.css">
<script src="__PUBLIC__/Admin/js/jquery-1.9.1.js"></script>
<script src="__PUBLIC__/Common/Layer/layer.js"></script>
<script>
function del(id){
	$("#del"+id+" td").css('background','#CBDFF2');
	parent.layer.confirm('真的要删除吗？', {
		btn: ['确认','取消'], //按钮
		shade: [0.5] //显示遮罩
	}, function(){
		$.post("{:U('Ad/ad_del')}", { "id": id},function(data){
			if(data.code == 1){
				parent.layer.msg(data.message, { icon: 1, time: 1000 }, function(){
						$("#del"+id).remove();
					});
			}else{
				parent.layer.msg(data.message, {icon: 2, time: 2000 }); 
			}
		}, "json");
	},function(){
		$("#del"+id+" td").css('border-top','0');
		$("#del"+id+" td").css('border-bottom','1px solid #EFEFEF');
	});
}

function refresh(){
	window.location.href=window.location.href;
}

//排序
function sort(){
	var str_id = '';
	var str_sort = '';
	$('input[name="id"]').each(function(){
		var id = $(this).val();
 		var sort_num = $('#sort_num'+id).val();
		str_id +=  ','+id;
		str_sort += ','+sort_num;
	});
	$.get("{:U('Ad/ad_sort')}", { str_id: str_id,str_sort:str_sort },function(data){
		if(data == 1){
			parent.layer.msg('排序成功', {
				icon: 1,
				shade: 0.3,
				time: 2000 //2秒关闭（如果不配置，默认是3秒）
			}, function(){
				window.location.href="__SELF__";
			});
		}else{
			layer.msg('排序失败');
		}
	});
}

function edit(id){
	var url = '{:U("Ad/ad_edit")}/id/'+id;
	url = url.replace('.html', '');
	parent.layer.open({
		type: 2,
		shadeClose: true,
		shade: 0.3,
		area: ['900px', '580px'],
		title: '编辑账号信息',
		content: url
	});
}
</script>
</head>
<body>
<div class="nav">
	<div class="nav_title">
    	<h4><img class="nav_img" src="__PUBLIC__/Admin/img/tab.gif" /><span class="nav_a"><if condition="$_GET['type'] eq 1">pc首页<elseif condition="$_GET['type'] eq 2"/>pc旅游<elseif condition="$_GET['type'] eq 3"/>pc会员专区<elseif condition="$_GET['type'] eq 4"/>pc合伙人专区<elseif condition="$_GET['type'] eq 5"/>手机首页<elseif condition="$_GET['type'] eq 6"/>手机旅游<elseif condition="$_GET['type'] eq 7"/>手机会员专区<elseif condition="$_GET['type'] eq 8"/>手机合伙人专区<else/><php>echo urldecode($_GET['menu_title']);</php></if></span></h4>
    </div>
</div>

<form action="__SELF__" method="POST">
<div class="search" style=" line-height:50px; padding-left:30px; margin-top:3px;">
    <button type="button" class="button" onclick="sort()">保存排序</button>
    <a href="{:U('Ad/ad_list', array('type' => 1))}"><button type="button" class="button">pc首页</button></a>
    <a href="{:U('Ad/ad_list', array('type' => 3))}"><button type="button" class="button">pc会员专区</button></a>
    <!--  <a href="{:U('Ad/ad_list')}?type=4"><button type="button" class="button">pc合伙人专区</button></a>-->
	<a href="{:U('Ad/ad_list', array('type' => 5))}"><button type="button" class="button">手机首页</button></a>
	<a href="{:U('Ad/ad_list', array('type' => 7))}"><button type="button" class="button">手机会员专区</button></a>
	 <!--<a href="{:U('Ad/ad_list')}?type=8"><button type="button" class="button">手机合伙人专区</button></a>-->
</div>
</form>

<div class="list">
	  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
      <thead>
	    <tr>
	      <td width="18%"><div align="center">排序</div></td>
	      <td width="18%"><div align="center">所属分类</div></td>
	      <td width="19%"><div align="center">检索分类</div></td>
	      <td width="27%"><div align="center">广告图片</div></td>
	      <td width="18%"><div align="center">操作</div></td>
        </tr>
        </thead>
        <tbody>
        <foreach name="result" item="vo">
	    <tr id="del{$vo.id}">
	      <td height="50"><div align="center">
          	  <input type="text" name="sort_num" id="sort_num{$vo.id}" style="width:60px;height:30px;text-align:center;font-size:14px;" value="{$vo.sort_num}">
              <input type="hidden" name="id" id="id{$vo.id}" value="{$vo.id}"/></div></td>
	      <td><div align="center">
	          {$vo.ad_space_name}
	      </div></td>
	      <td><div align="center">
	     		<if condition="$vo.type eq 1">pc首页
	     		<elseif condition="$vo.type eq 2"/>pc旅游
	     		<elseif condition="$vo.type eq 3"/>pc会员专区
				<elseif condition="$vo.type eq 4"/>pc合伙人专区
				<elseif condition="$vo.type eq 5"/>手机首页
				<elseif condition="$vo.type eq 6"/>手机旅游
				<elseif condition="$vo.type eq 7"/>手机会员专区
	     		<else/>手机合伙人专区</if>
	     	   </div>	
	      </td>
	      <td><div align="center">
	        <a target="_blank" href="{$vo.pic_url}"><img style="height:70px; width:200px; border-radius:4px; margin-top:5px;" src="{$vo.pic_url}" /></a>
          </div></td>
	      <td><div align="center">
	        <a class="a_button" href="javascript:;" onclick="edit({$vo[id]})">编辑</a>
	        <a class="a_button" href="javascript:;" onclick="del({$vo[id]})">删除</a></div></td>
        </tr>
        </foreach>
        </tbody>
  </table>
</div>

<!-- 分页 -->
<div class="page">
  <div align="center">{$page}</div>
</div>


</body>
</html>
